
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Spine.Unity;
using Spine;

public class TestChange : MonoBehaviour
{
    public SpineSkinDate[] array;//换局部皮的Sprite

    private SpineChangeSkin spineChangeSkin;
    private int index = 0;
    private SkeletonGraphic skeletonAnimation;
    private SkeletonDataAsset skeletonDataAsset;
    private Material sourceMaterial;
    private SkeletonData skeletonData;
    private void Start()
    {
        spineChangeSkin = GetComponent<SpineChangeSkin>();
        skeletonAnimation = GetComponent<SkeletonGraphic>();
        skeletonDataAsset = skeletonAnimation.SkeletonDataAsset;
        sourceMaterial = skeletonDataAsset.atlasAssets[0].PrimaryMaterial;
        skeletonData = skeletonAnimation.Skeleton.Data;

       
    }

    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            if (array == null || array.Length < 1) return;
            if (index >= array.Length)
                index = 0;

            var skinData = array[index];
            index++;
            spineChangeSkin?.ChangeShin(skinData.slotName, skinData.attachmentName, skinData.sprite);
        }
    }
}
[Serializable]
public struct SpineSkinDate
{
    public string slotName;
    public string attachmentName;
    public Sprite sprite;

}
